<?php


class MyFormHelper extends FormHelper {
  
  var $helpers = array('Html');
  
  /**
   * inputsDisabledAndHidden()  Returns a 'Form->input' that is disabled and a 'Form->hidden' for the same item.
   * 
   * @author Jason Frank 8/3/2011
   * @param string $modelField  The typical model database field to use for the input in the form: .Modelname.fieldname'.
   * @param array  $options     Any additional options to be applied to the 'Form->input' besides 'disabled=>true'. 
   */
  function inputsDisabledAndHidden($modelField, $options = array()) {
    
    $myOptions = array();
    $myOptions['disabled'] = 'true';
    
    foreach ($options as $key => $value) {
      $myOptions[$key] = $value;
    }
    
    $retval  = $this->input( $modelField, $myOptions); // uses parent class's method
    $retval .= $this->hidden($modelField);  // uses parent class's method
    
    return $retval;
  } ///////////// end func //////////////////////
  
  /**
   * Special case for the fields that will recieve values DYNAMICALLY via jQuery
   * 
   * Be sure that $inputType is lower case.  Assumes there is a CSS class ".hide" that has its stuff hidden
   */
  function dynamicInputsDisabledAndHidden($modelField, $identifyingDivClass, $inputType, $options = array()) {
    
    $classes = "input $inputType $identifyingDivClass";
    
    $myOptions = array();
    foreach ($options as $key => $value) {
      $myOptions[$key] = $value;
    }
    $myOptions['div']  = $classes;
    $myOptions['type'] = $inputType;
    $myOptions['disabled'] = 'true';
    
          //$options = array('div'=>$classes, 'type'=>"$inputType", 'disabled'=>'true');
          
    // the disabled input:
    $retval  = $this->input($modelField, $myOptions);
    // the hidden input (wrapped in a div so we can add a class that jQuery can grab)
    $retval .=  $this->Html->div(/*class:*/"$identifyingDivClass hide",$this->hidden($modelField));
    
    return $retval;
  } ////////////// end func ////////////////

} //////////////////////// end class ////////////////////////////////

?>
